let color = "{COOKIE_color}";
$(function () {
    let a = location.search.split("=")[1];
    if (a) {
        $("#title").text(`${a}的访问记录`);
        $("#table-col1").text("请求时间");
        $("#table-col2").text("请求路径");
        $("#table-col3").text("请求参数");
        $.post("./?/getIPVisitData",{
            IP:a
        },function (text) {
            console.log(text);
            let data = JSON.parse(text);
            let content = ``;
            for (const key in data) {
                let value = data[key];
                let x = `<tr><td>${value.Time}</td><td>${value.Path}</td><td>${value.Args}</td></tr>`.replace(String.fromCharCode(92),"");
                content += x;
            }
            $("#main-div").html(content);
            loadColor();
        });
    } else {
        $.post("./?/getIPVisitorList", {}, function (text) {
            let data = JSON.parse(text);
            let content = ``;
            for (const key in data) {
                let value = data[key];
                let x = `<tr><td>${key}</td><td>${value}</td><td><a href="./?/visitLog&IP=${key}" class="btn btn-flat waves-button waves-effect waves-light">查看详情</a></td></tr>`;
                content += x;
            }
            $("#main-div").html(content);
            loadColor();
        });
    }
});